<template>
    <div class="root">
        <div v-if="shop.shop_sales" class="shop-left">
            <div class="row-act" v-for="(act, k) in shop.shop_sales">
                <image resize="cover" class="act-img" :src="act.img"></image>
                <text class="act-txt">{{act.left}}</text>
                <text class="act-txt" v-if="act.right">{{act.right}}</text>
            </div>
        </div>

        <div v-if="shop.midcartsale" class="shop-right" @click="goToShop">
            <text class="shop-sale">{{shop.midcartsale}}</text>
            <image class="right-arrow-icon" resize="cover" :src="rightArrowImg"></image>
        </div>
    </div>
</template>
<style scoped>
.root {
    flex-direction: row;
    justify-content: flex-end;
    align-items: center;
    height: 70px;
    padding-left: 30px;
    padding-right: 30px;
    background-color: #fff;
}
.shop-left{
    flex: 1;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
}
.row-act {
    margin-right: 28px;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
}
.act-img {
    width: 46px;
    height: 28px;
    margin-right: 4px;
}
.act-txt {
    font-size: 24px;
    color: #313131;
    font-family: msyhl;
}
.shop-right {
    flex-direction: row;
    justify-content: flex-end;
    align-items: center;
}
.shop-sale {
    font-size: 26px;
    color: #e31336;
    font-family: msyhl;
}
.right-arrow-icon {
    width: 36px;
    height: 36px;
    margin-left: 4px;
}
</style>
<script>
    import rightArrowImg from 'assets/images/right-arrow.png';
    import navigator from "utils/navigator";
    import route from 'constants/route';

    export default{
        props: {
            shop: {
                type: Object,
                default:{},
                required: true
            }
        },
        data(){
            return{
                rightArrowImg: rightArrowImg
            }
        },
        methods: {
            goToShop(){
                navigator.pop();//关闭当前购物车页面
                
                if(this.shop.shoptype){ //大店铺shoptype
                    let _options = {
                        url: route.shop_index,
                        title: this.shop.sname || "商家店铺",
                        params: {
                            shopType: this.shop.shoptype
                        }
                    };
                    navigator.push(_options);
                } else {  //小店铺sid
                    let _options = {
                        url: route.shop_plus,
                        title: this.shop.sname || "店铺详情",
                        params: {
                            sid: this.shop.sid
                        }
                    };
                    navigator.push(_options);
                }
            }
        }
    }
</script>
